package src.main.java.org.stringBuilder;

import java.util.StringJoiner;

public class Test3 {
    public static void main(String[] args) {
        StringJoiner joiner = new StringJoiner(",");
        joiner.add("java1");
        joiner.add("java2");
        joiner.add("java3");
        System.out.println(joiner);
        System.out.println("=============");
        StringJoiner joiner1 = new StringJoiner(",", "[", "]");
        joiner1.add("java4");
        joiner1.add("java5");
        joiner1.add("java6");
        System.out.println(joiner1);
        System.out.println("==================");
        System.out.println(getArrayData(new int[]{11, 22, 33}));
        System.out.println("=========");
        Runtime runtime = Runtime.getRuntime();
        System.out.println(runtime.totalMemory()/1024/1024);

    }

    public static String getArrayData(int[] arr){
        if(arr == null){
            return null;
        }
        StringJoiner stringJoiner = new StringJoiner(",", "[", "]");
        for (int i = 0; i < arr.length; i++) {
            stringJoiner.add(arr[i]+"");
        }
        return stringJoiner.toString();

    }
}
